(function () {
    'use strict';

    angular
        .module('logcenterApp')
        .service('SvcAnalysisService',SvcAnalysisService);

    SvcAnalysisService.$inject=['$http','$q'];
    function SvcAnalysisService($http,$q) {
        var query=function (partition, beginDateTime, endDateTime,svcName) {
            var deferred=$q.defer();
            $http.get('api/dashboard/serverexecuteinfo?partition='+partition+'&startTime='
                + beginDateTime + '&endTime=' + endDateTime+ '&svcName='+ svcName).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };

        var queryDetail = function (partition, pid, beginDateTime, endDateTime) {
            var deferred=$q.defer();
            $http.get('api/dashboard/svcexecuteinfo?partition=' + partition+'&pid='+pid
            + '&startTime='+ beginDateTime + '&endTime=' + endDateTime).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };

        var querySvrExecPer10MinInfo=function (partition, beginDateTime, endDateTime,svcName) {
            var deferred=$q.defer();
            $http.get('api/dashboard/svc10minutesexecuteinfo?partition='+partition+'&startTime='
                + beginDateTime + '&endTime=' + endDateTime + '&svcName='+ svcName).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };

        var querySvrExecPer10MinInfoDetail = function (key) {
            var deferred=$q.defer();
            $http.get('api/dashboard/svctop5executeinfo?key=' + key).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };

        // var querySlowServiceTop10 = function (partition, logmsg,beginDateTime, endDateTime) {
        //     var deferred=$q.defer();
        //     $http.get('/api/dashboard/callService?partition=' + partition+"&logmsg ="+logmsg
        //         + '&startTime='+ beginDateTime + '&endTime=' + endDateTime).then(function (resp) {
        //         deferred.resolve(resp.data);
        //     },function (error) {
        //         deferred.reject(error);
        //     });
        //     return deferred.promise;
        // };


        return {
            query:query,
            queryDetail:queryDetail,
            querySvrExecPer10MinInfo:querySvrExecPer10MinInfo,
            querySvrExecPer10MinInfoDetail:querySvrExecPer10MinInfoDetail,
           // querySlowServiceTop10:querySlowServiceTop10

        };
    }
})();
